package com.ruoyi.hr.controller.hr.salaryadmin;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.hr.domain.welfare.welfareopen.WelfareOpen;
import com.ruoyi.hr.service.salaryadmin.SalaryAdminService;
import com.ruoyi.hr.service.welfare.WelfareService;
import com.ruoyi.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 薪管理模块
 * @date 2020/2/18
 */
@Controller
@RequestMapping("/salaryAdmin")
public class SalaryAminController extends BaseController {

    @Autowired
    SalaryAdminService salaryAdminService;


    private String prefix = "hr/salaryadmin";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String user() {
        return prefix + "/salaryAdmin";
    }

    /**
     * 欢迎
     */
    @GetMapping("/welcome")
    public String welcome() {
        return prefix + "/welcome";
    }

    /**
     * 加载薪资管理左侧树状
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Ztree> treeData() {
        List<Ztree> ztrees = new ArrayList<Ztree>();
        Ztree ztree[] = {
                new Ztree((long) 100, (long) 0, "薪资信息", "薪资信息"),
                new Ztree((long) 101, (long) 100, "薪资信息(发薪员工)", "薪资信息(发薪员工)"),
                new Ztree((long) 102, (long) 100, "薪资信息(所有员工)", "薪资信息(所有员工)"),
                new Ztree((long) 103, (long) 100, "当月入职", "当月入职"),
                new Ztree((long) 104, (long) 100, "当月离职", "当月离职"),
                new Ztree((long) 105, (long) 100, "当月转正", "当月转正"),
                new Ztree((long) 106, (long) 100, "当月调薪", "当月调薪"),
                new Ztree((long) 107, (long) 100, "拜特薪资信息(所有员工)", "拜特薪资信息(所有员工)"),

                new Ztree((long) 108, (long) 0, "薪资开启", "薪资开启"),
                new Ztree((long) 109, (long) 108, "薪资开启", "薪资开启"),
                new Ztree((long) 110, (long) 108, "薪资开启历史", "薪资开启历史"),

                new Ztree((long) 111, (long) 0, "基本薪资变动", "基本薪资变动"),
                new Ztree((long) 112, (long) 111, "薪资变动登记", "薪资变动登记"),
                new Ztree((long) 113, (long) 111, "薪资变动历史", "薪资变动历史"),


                new Ztree((long) 114, (long) 0, "止薪日期修改", "止薪日期修改"),
                new Ztree((long) 115, (long) 114, "薪资信息(离职)", "薪资信息(离职)"),

                new Ztree((long) 116, (long) 0, "薪资变动错误纠正", "薪资变动错误纠正"),
                new Ztree((long) 117, (long) 116, "薪资变动纠错", "薪资变动纠错"),
                new Ztree((long) 118, (long) 116, "薪资变动纠错历史", "薪资变动纠错历史"),

                new Ztree((long) 119, (long) 0, "薪资开启错误纠正", "薪资开启错误纠正"),
                new Ztree((long) 120, (long) 119, "薪资开启纠错", "薪资开启纠错"),
                new Ztree((long) 121, (long) 119, "薪资开启纠正历史", "薪资开启纠正历史"),
        };
        for (int i = 0; i < ztree.length; i++) {
            ztrees.add(ztree[i]);
        }
        return ztrees;
    }

    /**
     * 根据pgid查所有项目名称
     *
     * @param pgid
     * @return
     */
    @RequestMapping("/findProByPgid")
    @ResponseBody
    public List<String> findProByPgid(String pgid) {
        List<String> list = salaryAdminService.findProByPgid(pgid);
        return list;
    }

    /**
     * 根据pgid查询所有项目对象
     *
     * @param pgid
     * @return
     */
    @RequestMapping("/findProObject")
    @ResponseBody
    public List<Map<String, Object>> findProObject(String pgid) {
        return salaryAdminService.findProObject(pgid);
    }

    @RequestMapping("/findAllPro")
    @ResponseBody
    public List<String> findAllPro() {
        return salaryAdminService.findAllPro();
    }


    @RequestMapping("findAddEmpList")
    @ResponseBody
    public TableDataInfo findAddEmpList() {
        return getDataTable(salaryAdminService.findAddEmpList());
    }
}
